package cn.wolfcode.wolf2w.common.core.query;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

import java.io.Serializable;

@ApiModel(value = "分页查询对象",description = "分页查询对象")
@Getter
@Setter
public class QueryObject implements Serializable {
    @ApiModelProperty(value = "当前页码",example = "1",name = "currentPage",required = false,dataType = "int")
    private int currentPage = -1;
    @ApiModelProperty(value = "每页显示条数",example = "1",name = "pageSize",required = false,dataType = "int")
    private int pageSize = 10;
    @ApiModelProperty(value = "每页显示条数",example = "5",name = "pageNum",required = false,dataType = "int")
    private int pageNum = -1;
    @ApiModelProperty(value = "关键字",example = "关键字",name = "keyword",required = false,dataType = "String")
    private String keyword;

    public int getCurrentPage(){
        if(currentPage != -1){
            return this.currentPage;
        }
        if(currentPage == -1 && pageNum != -1){
            return pageNum;
        }
        return 1;
    }

    public int getPageNum(){
        if(pageNum != -1){
            return this.pageNum;
        }
        if(pageNum == -1 && currentPage != -1){
            return currentPage;
        }
        return 1;
    }
}
